<?php
	require_once 'Content.php';
	class Image extends Content{

		private $img_header;
		private $date;
		private $order;
		
		
		public function __construct($name,$text="",$date="9999-01-01",$img_header,$order){
			if (!$this->setName($name)) {
				echo "You must enter valid picture name!!!";
				return;
			}
			
			$this->setText($text);
			$this->setImgToHeader($img_header);
			$this->setDate($date);
			$this->setOrder($order);
		}

		
		public function setName($name){
			if (is_string($name) && ( !strcasecmp(substr($name,-4), ".jpg") || !strcasecmp(substr($name,-4), ".gif") || !strcasecmp(substr($name,-4), ".png") || !strcasecmp(substr($name,-5), ".jpeg")  )){
				$this->name= $name;
				return 1;
			} else return 0;
		}


		public function setImgToHeader($header){
			if ( $header== "0" || $header =="1"){
					$this->img_header = $header;
			}
		}
		public function getImgToHeader(){
			return $this->img_header;
		}
		public function setDate($date="9999-01-01"){
			if (is_string($date) 						&& strlen($date)== 10 		&&  
				substr($date, 0,4) >=1000 				&& substr($date,0,4)<=9999 	&&
				substr($date, 5,2) >=1 					&& substr($date,5,2)<=12 	&&
				substr($date, 8,2) >=1 					&& substr($date,8,2)<=31 	&& 
				!strcasecmp("-", substr($date, 7,1))	&& !strcasecmp(substr($date,4,1), "-") )
			{
				
				$this->date= $date;
			}
		}
		public function getDate(){
			return $this->date;
		}
		public function setOrder($order){
			if (is_string($order)){
				$this->order= $order;
			} else $this->order=0;
		}
		public function getOrder(){
			return $this->order;
		}	
	}

?>